Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor BJData fixes #3637

Merged
merged 2 commits into from
Aug 3, 2022
Merged

Conversation

falbrechtskirchinger
Copy link
Contributor

These are the previously discussed minor fixes to the BJData binary_reader code.

  • Replace the std::vector/std::map lookup tables with std::arrays.
    This is meant to be an optimization (mostly avoiding unnecessary, repeated heap allocations). Whether std::lower_bound() is actually faster than std::find/std::find_if in this scenario is unknown.

  • Replace string_t::npos with binary_reader::npos.

@coveralls
Copy link

coveralls commented Jul 31, 2022

Coverage Status

Coverage remained the same at 100.0% when pulling 98ef5b5 on falbrechtskirchinger:bjdata-fixes into df98ca2 on nlohmann:develop.

@falbrechtskirchinger
Copy link
Contributor Author

falbrechtskirchinger commented Aug 2, 2022

Wow! This improves performance parsing a 136M document by 0.3%. This was truly worth it! 🤣

(It still avoids heap allocations, though.)

@falbrechtskirchinger falbrechtskirchinger force-pushed the bjdata-fixes branch 2 times, most recently from 8b66859 to b0f6dcd Compare August 2, 2022 07:35
@falbrechtskirchinger
Copy link
Contributor Author

Looks good to me.

Copy link
Owner

@nlohmann nlohmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@nlohmann nlohmann added the aspect: binary formats BSON, CBOR, MessagePack, UBJSON label Aug 2, 2022
@nlohmann nlohmann added this to the Release 3.11.2 milestone Aug 3, 2022
@nlohmann nlohmann merged commit 3224202 into nlohmann:develop Aug 3, 2022
@falbrechtskirchinger falbrechtskirchinger deleted the bjdata-fixes branch August 3, 2022 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aspect: binary formats BSON, CBOR, MessagePack, UBJSON
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants